﻿using IdentityServer4.Models;
using IdentityServer4.Test;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace IdentityServer4Sample.Util
{
    public class Config
    {
        public static IEnumerable<ApiResource> GetResources()
        {
            return new List<ApiResource>() {
                new ApiResource("api","myApi")
            };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>() {
                new Client()
                {
                    ClientId="client",
                    AllowedScopes={"api" },
                    AllowedGrantTypes=GrantTypes.ClientCredentials,
                    ClientSecrets={ new Secret("p@ssw0rd".Sha256())}
                },
                new Client(){
                    ClientId="passwordClient",
                    AllowedScopes={ "api"},
                    AllowedGrantTypes=GrantTypes.ResourceOwnerPassword,
                    ClientSecrets={ new Secret("p@ssw0rd".Sha256()) }
                }
            };
        }

        public static IEnumerable<TestUser> GetUsers()
        {
            return new List<TestUser>()
            {
                new TestUser(){
                    Username ="admin",
                    Password="p@ssw0rd",
                    SubjectId="admin"    
                }
            };
        }
    }
}

